package com.qf.controller;

import com.qf.pojo.Clinicinfo;
import com.qf.service.ClinicinfoService;
import com.qf.utils.UploadUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * @author H
 * @create 2020-10-12 20:13
 * @Description: 诊所信息
 */
@RestController
@RequestMapping("/clinicinfo")
public class ClinicinfoController {
    @Autowired
    ClinicinfoService clinicinfoService;

    @RequestMapping("/findAll")
    @RequiresPermissions(value = {"user_find"})
    public List<Clinicinfo> findAll() {
        return clinicinfoService.findAll();
    }

    @RequiresPermissions(value = {"user_find"})
    @RequestMapping("/findById")
    public Clinicinfo findById(@RequestBody Map map) {
        Integer id = (Integer) map.get("id");
        return clinicinfoService.findById(id);
    }

    @RequiresPermissions(value = {"user_edits"})
    @RequestMapping("/saveOrUpdate")
    public String saveOrUpdate(@RequestBody Clinicinfo Clinicing) {
        return clinicinfoService.saveOrUpdate(Clinicing);
    }

    @RequestMapping("/upload")
    public String upload(@RequestParam("file") MultipartFile multipartFile) {
        System.out.println(multipartFile.getOriginalFilename());
        UploadUtils uploadUtils = new UploadUtils();
        String upload = uploadUtils.upload(multipartFile);
        return upload;
    }
}
